CROSS	?= arm-linux-
NAME	:= libc.a

CC		= $(CROSS)gcc
LD 		= $(CROSS)ld
OBJCOPY	= $(CROSS)objcopy
OBJDUMP	= $(CROSS)objdump
AR		= $(CROSS)ar

INCDIR	:= $(shell pwd)/../include
# C预处理器的flag，flag就是编译器可选的选项
CPPFLAGS	:= -nostdlib -nostdinc -I$(INCDIR)
# C编译器的flag
CFLAGS		:= -Wall -O2 -fno-builtin

OBJS := div64.o lib1funcs.o ctype.o muldi3.o printf.o string.o vsprintf.o

$(NAME): $(OBJS)
	@echo [AR] $^
	@${AR} -r -o $@ $^
	
%.o:%.c
	@echo [CC] $<
	@${CC} $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

%.o:%.S
	@echo [CC] $<
	@${CC} $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

clean:
	rm -f $(NAME) *.o		

.PHONY: clean
